/*
 * @title: 全局settings变量
 * @author: andy.ten@tom.com & xukaixing@hotmail.com
 * @Date: 2022-03-30 23:13:05
 * @LastEditors: andy.ten@tom.com
 * @LastEditTime: 2022-04-16 10:45:00
 * @version: 1.0.3
 * @copyright: copyright (c) 2022 andyten
 *  node: you can not copy and/or use and/or modify this program free,
 *  please reserve the segment above.Please mail me if you have any question.
 */

import defaultSettings from '@/settings';
import config from '@/store/config';

const { showSettings, tagsView, fixedHeader, sidebarLogo, supportPinyinSearch, uniqueOpened, layoutSize } = defaultSettings;

const state = {
  theme: '#cf2931',
  showSettings,
  tagsView,
  fixedHeader, // 固定tagsView栏
  sidebarLogo, // 侧边栏顶部logo
  uniqueOpened,
  supportPinyinSearch, // 顶部搜索框支持拼音检索
  layoutSize
};

const mutations = {
  [config.SET_CHANGE_SETTING]: (state, { key, value }) => {
    // eslint-disable-next-line no-prototype-builtins
    if (state.hasOwnProperty(key))
      state[key] = value;
  }
};

const actions = {
  changeSetting({ commit }, data) {
    commit(config.SET_CHANGE_SETTING, data);
  }
};

export default {
  namespaced: true,
  state,
  mutations,
  actions
};

